<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>事件流，冒泡事件</title>
</head>
<style>
    #outer{
        position: absolute;
        width: 300px;
        height: 300px;
        left: 50px;
        top: 30px;
        background: #903ff9;
    }
    #inner{
        position: absolute;
        width: 200px;
        height: 200px;
        left: 500px;
        background: #ee97ad;
    }
    #btn{
        position: absolute;
    }

</style>

<body>
    <div id="outer">
        <div id="inner">

            <button id="btn">按钮</button>
        </div>
    </div>

</body>
<script>
    // 当只存在outer的onclick方法时，子元素也可触发outer的点击事件
    outer.onclick = function(e){
     
        console.log("outer");
    }

    inner.onclick = function(e){
        e.stopPropagation();
        
        console.log("inner");
    }
    btn.onclick = function(e){
        e.stopPropagation();
        console.log("btn"); 
    }



</script>

</html>